package com.annhoa.core.base;

import java.util.Map;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import com.annhoa.util.PageData;

public interface DAO {
	/**
	 * 保存对象
	 * @param sql
	 * @param obj
	 * @return
	 * @throws Exception
	 */
	public Object save(String sql, Object obj) throws Exception;
	
	/**
	 * 修改对象
	 * @param sql
	 * @param obj
	 * @return
	 * @throws Exception
	 */
	public Object update(String sql, Object obj) throws Exception;
	
	/**
	 * 删除对象 
	 * @param sql
	 * @param obj
	 * @return
	 * @throws Exception
	 */
	public Object delete(String sql, Object obj) throws Exception;

	/**
	 * 查找对象
	 * @param sql
	 * @param obj
	 * @return
	 * @throws Exception
	 */
	public Object findForObject(String sql, Object obj,Class<?> clazz) throws Exception;

	/**
	 * 查找对象
	 * @param sql
	 * @param obj
	 * @return
	 * @throws Exception
	 */
	public Object findForList(String sql, Object obj,Class<?> clazz) throws Exception;
	
	/**
	 * 查找对象封装成Map
	 * @param s
	 * @param obj
	 * @return
	 * @throws Exception
	 */
	public Object findForMap(String sql, Object obj, String key , String value) throws Exception;

	/**
	 * 查找对象封装成Page<Map>
	 * @param sql
	 * @param pageable
	 * @param args
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("rawtypes")
	//public Page<Map> findPageByParams(String sql, Pageable pageable, Object... args)throws Exception;
	
	public Page<Map> findPageByParams(String sql, Pageable pageable, PageData pd)throws Exception;
	
	public Page<Map> findPageByParams(BasePage page)throws Exception;
}
